﻿//用以生成E01命令函数
var EnumE01Offset = {
    GPRSConnectWay : "0000",//GPRS连接模式
    TrackTimes:"0001", //追踪上报次数
    TrackInterval:"0003", //GPRS追踪时间间隔
    EngineOffInterval:"0005", //引擎关闭上传间隔时间
    APN:"0007", //APN
    APNUserName:"0027", //APN用户名
    APNPassword:"0047", //APN密码
    TrackerID:"0067", //设备编号
    DNS:"0077", //DNS
    IP1:"0087",//IP1
    Port1:"00A7", //Port1
    IP2:"00AC",//IP2
    Port2:"00CC",//Port2
    IP3:"00D1",//IP3
    Port3:"00F1",//Port3
    //["00F6", 10],
    GeoFence:"0100", //8个电子围栏
    SMSAuth:"0180", //8组授权配置选项号码
    SMSTimeZone:"0280", //短信时区
    RunDistance:"0284", //运行距离
    RunTime:"0288", //运行时间
    DistanceInterval:"028C", //定距追踪距离间隔
    Turn:"028E", //转弯报告角度值
    MaxSpeed:"0290", //超速报警
    ExternalPowerLow:"0294", //外部电源低电压9~36V,(90-360)报警值
    Heartbeat:"0296", //心跳包定时间隔
    LogInteravl:"0298", //记录仪记录时间间隔
    Sensor:"029A", //振动灵敏度
    //["029B", 1], //
    SensorWhenSleep:"029C", //睡眠时的振动灵敏度
    SensorWhenWakeup:"029D", //退出睡眠时的振动灵敏度
    Tow:"029E", //拖车警告
    GPSOnTime:"029F", //GPS模块打开时间 = 0常开
    GPSOffTime:"02A0", //GPS模块关闭时间
    BatteryLow:"02A1", //电池低电压报警电压
    //["02A2", 1], //输出状态备份或叫保存
    
    AccInputGPSleep:"02A4", //点火状态的GPS省电模式
    DCInputGPSSleep:"02A5", //DC输入时GPS省电模式
    GPRSTimeZone: "02A9", //GPRS时区
    LEDOff: "02A6", //LED
    BuzzerOff:"02A7",
    ProtocolType: "02AA",
    EngineCheck:"02B8", //使能引擎检测，
//    ["02B9", 2], 
//    ["02BB", 2],
//    ["02BD", 1],
//    ["02BE", 1],
//    ["02BF", 1],
//    ["02C0", 64],
    TrackerPassword:"0300",//设备密码
    TrackingNumber:"0310", //短信追踪号码
    SMSTrackInterval:"0320", //短信追踪时间间隔
    SMSTrackTimes:"0322", //短信追踪上报次数
    GPRSAuth:"0330", //GPRS事件标志位
    //ASCSMSHeader: "0340", //英文短信字符
    Input1Activate_Message: "0340",
    Input2Activate_Message: "0350",
    Input3Activate_Message: "0360",
    Input4Activate_Message: "0370",

    Input5Activate_Message: "0380",
    Input1NotActivate_Message: "03C0",
    Input2NotActivate_Message: "03D0",

    Input3NotActivate_Message: "03E0",
    Input4NotActivate_Message: "03F0",
    Input5NotActivate_Message: "0400",
    BuiltinLowVoltage_Message: "0440",
    OutlayLowVoltage_Message: "0450",
    OverSpeedAlarm_Message: "0460",
    EnterGEO_Message: "0470",
    ExitGEO_Message: "0480",
    OutlayPowerOn_Message: "0490",
    OutlayPowerOff_Message: "04A0",
    NotFixGPRS_Message: "04B0",
    FixGPRS_Message: "04C0",
    EnterSleep_Message: "04D0",
    ExitSleep_Message: "04E0",
    GPRSAntennaCut_Message: "04F0",

    Reboot_Message: "0500",
    CrashAlarm_Message: "0510",
    DistanceTracing_Message: "0540",
    DemandInfoNow_Message: "0550",
    IntervalTracting_Message: "0560",
    TowAlarm_Message: "0570",

    //["0660", 240],//
    PhotoAuth:"0750", //拍照事件标示位
    UnicodeSMSHeader:"0760", //中文短信字符
    GeoFenceName:"0A80" //围栏地址名
    
};

var E01Array = [ //第一个为Offset，第二个为字节长度
    ["0000", 1], //GPRS连接模式
    ["0001", 2], //追踪上报次数
    ["0003", 2], //GPRS追踪时间间隔
    ["0005", 2], //引擎关闭上传间隔时间
    ["0007", 32], //APN
    ["0027", 32], //APN用户名
    ["0047", 32], //APN密码
    ["0067", 16], //设备编号
    ["0077", 16], //DNS
    ["0087",32],//IP1
    ["00A7", 5], //Port1
    ["00AC", 32],//IP2
    ["00CC", 5],//Port2
    ["00D1", 32],//IP3
    ["00F1", 5],//Port3
    ["00F6", 10],
    ["0100", 16], //8个电子围栏
    ["0180", 32], //8组授权配置选项号码
    ["0280", 4], //短信时区
    ["0284", 4], //运行距离
    ["0288", 4], //运行时间
    ["028C", 4], //定距追踪距离间隔
    ["028E", 2], //转弯报告角度值
    ["0290", 2], //超速报警
    ["0294", 2], //外部电源低电压9~36V,(90-360)报警值
    ["0296", 2], //心跳包定时间隔
    ["0298", 2], //记录仪记录时间间隔
    ["029A", 1], //振动灵敏度
    ["029B", 1], //
    ["029C", 1], //睡眠时的振动灵敏度
    ["029D", 1], //退出睡眠时的振动灵敏度
    ["029E", 1], //拖车警告
    ["029F", 1], //GPS模块打开时间 = 0常开
    ["02A0", 1], //GPS模块关闭时间
    ["02A1", 1], //电池低电压报警电压
    ["02A2", 1], //输出状态备份或叫保存
    ["02A3", 1], //GPS睡眠时省电模式
    ["02A4", 1], //点火状态的GPS省电模式
    ["02A5", 1], //DC输入时GPS省电模式
    ["02A9", 4], //GPRS时区
    ["02AA", 1], //
    ["02B8", 1], //使能引擎检测，
    ["02B9", 2], 
    ["02BB", 2],
    ["02BD", 1],
    ["02BE", 1],
    ["02BF", 1],
    ["02C0", 64],
    ["0300", 4], //设备密码
    ["0310", 16], //短信追踪号码
    ["0320", 2], //短信追踪时间间隔
    ["0322", 2], //短信追踪上报次数
    ["0330", 16], //GPRS事件标志位
    ["0340", 900], //英文短信字符定
    ["0660", 240],//
    ["0750", 16], //拍照事件标示位
    ["0760", 900], //中文短信字符
    ["0A80", 108], //围栏地址名
    ["0B00", 1],
    ["0B01", 4],
    ["0B05", 1],
    ["0B06", 1],
    ["0B07", 1],
    ["0B08", 1],
    ["0B09", 32],
    ["0B29", 32],
    ["0B49", 16],
    ["0B59", 16],
    ["0B69", 16],
    ["0B89", 16],
    ["0B99", 16],
    ["0BA9", 16],
    ["112F", 20],
    ["114F", 20],
    ["116F", 2]
];

function getHexE01StringASC(offset,str){
    return getHexE01String(offset,StringToASCHex(str));
}

function getHexE01WriteString(offset,datahex){
    var len = datahex.length/2;
    var lenhex = UInt16ToWORDStringNoComm(len);
    return offset + lenhex + datahex;
}

function getHexE01ReadString(offset,len){
    var lenhex = UInt16ToWORDStringNoComm(len);
   return offset + lenhex;
}


